import './index.less';

import React from 'react';
import { inject, observer } from 'mobx-react';

import { Modal, Row, Col, Button, Popover, message, Spin, Checkbox, Icon } from 'antd';
import {
    WeaTools,
    WeaRightMenu,
    WeaBrowser,
    WeaLocaleProvider,
    WeaPopoverHrm,
    WeaCheckbox,
    WeaInput,
    WeaInputNumber,
    WeaDialog,
} from 'ecCom'
import OGroup from './OGroup'
import NodeOperator from './NodeOperator'
import objectAssign from 'object-assign';
import * as SignUtil from '../../util/signUtil';
import SignInputck from '../wf-sign-input/index';
import RemindTypelist from '../wf-remind-typelist';

import trim from 'lodash/trim'
import isEqual from 'lodash/isEqual';
import * as mobx from 'mobx';
import { toJS, observable } from 'mobx'

const warning = Modal.warning;
const confirm = Modal.confirm;
const getLabel = WeaLocaleProvider.getLabel;

@observer
export default class Forwardck extends React.Component {
    constructor(props) {
        super(props);
    }

  render () {
      //inOdoc 是否是公文使用
        let { wfForwardStore,inOdoc = false} = this.props;
        const {
            showForward,
            isshownodeoperators,
            isshowoperategroup,
            signinput = {},
            operatorDatas,
            loading,
            selectOperatorsMax,
            loaded,
            isdisabledbtns,
            isClear,
            formParams = {},
            initRemarkContent,
            remarkMap,
            chuanyueInfo,
            remindTypes,
            replyNoticeInfo = {},
            fwLimitInfo = {},
            isFormSignature
        } = wfForwardStore;
        let {remindInfo} = wfForwardStore;
        const { use_textarea_signinput, isannexupload_edit, isSignDoc_edit, isSignWorkflow_edit,remarkInfo={} , isSignLocation_edit } = signinput;
        const { handWrittenSignSwitch } = remarkInfo;
        const { showReplyNotice,noticeLabel} = replyNoticeInfo;
        const {isopen = '',choiceoperator = ''} = fwLimitInfo;
        const { IsSubmitedOpinion, IsBeForwardTodo, field5, forwardflag = '1', feedbacksign = '', requestid = -1 , isSubmitSign = '0', isChuanyue = '0', isRemind = '0',remark = '', isOpenTakOvertime='0',isShowReplyNotice, isMulitTak, workflowRequestLogId} = formParams;
        const { handleVisibleChange, handleShowNodeOperator, setOperatorIds, dropAllUserGroup } = wfForwardStore;
        const {submitSignName, chuanyueName, remindName} = chuanyueInfo;

        const { isforwardrights = '', requestname = '', isHideInput = '', IsSubmitedOpinionShowname = getLabel('81777', "可提交意见"), IsBeForwardTodoShowname = getLabel('81776', "可转发"),customBtnInfo = {} } = signinput;
        //自定义按钮信息
        const {receiveLabelInfo = {}, nodeOperatorTitleInfo = {}, overTimeTakInfo = {}} = customBtnInfo;
        let receiveLabelSpan = receiveLabelInfo[forwardflag] || '';
        let nodeOperatorTitle = nodeOperatorTitleInfo[forwardflag] || '';
        const remarkMustInput = this.verifyRemarkMustInput(signinput,forwardflag);

        let _forwardheight = isforwardrights == '1' ? 479 : 439;
        const ishideinput = isHideInput == '1';
        if (ishideinput) {
            _forwardheight = _forwardheight - 175;
        }
        remindInfo = {...remindInfo,...{value : remindTypes}};
        let receiveLabel = getLabel('24965', "转发接收人");
        if (forwardflag == "2") receiveLabel = getLabel('126454', "意见征询接收人");
        if (forwardflag == "3") receiveLabel = getLabel('386179', "转办接收人");
        if (forwardflag == "4") receiveLabel = getLabel(382672,'传阅接收人');
        if (forwardflag == "5") receiveLabel = getLabel(510498,'征询转办接收人');

        if(receiveLabelSpan.length > 0) receiveLabel = receiveLabelSpan;

        if (feedbacksign == "4") receiveLabel = getLabel('386180', "意见反馈接收人");
        let isHasRemark = false;
        let i = 0;
        remarkMap.forEach((value, key, map) => {
            if (key) {
                i++;
            }
        })
        if (JSON.stringify(toJS(remarkMap)) === "{}" || (toJS(remarkMap).key_0 === '' && i <= 1)) {
            isHasRemark = false;
        } else {
            isHasRemark = true;
        }

        const agent = (
            <span style={{ color: "#A0A0A0" }}>{getLabel(388045, "您当前正在代理")}
                <a href={`javaScript:openhrm(${signinput.tempbeagenter});`} onClick={e => window.pointerXY(e)} title={signinput.tempbeagentername}>
                    <span style={{ color: "#4D7AD8", verticalAlign: "initial", cursor: "pointer", marginLeft: "0" }}>{signinput.tempbeagentername}</span>
                </a>
                {getLabel(84398, "进行操作")}</span>
        )

        let compHeight = '195px';
        if(isFormSignature==1){
            if(!this.hasBottomConfig()){
                compHeight = "260px";
            }else{
                if(use_textarea_signinput == 1){
                    compHeight = "290px";
                }else{
                    compHeight = "300px";
                }
            }
        }else {
            if(use_textarea_signinput == 1){
                compHeight = '260px';
            }else if (handWrittenSignSwitch == 1 || isannexupload_edit|| isSignDoc_edit|| isSignWorkflow_edit ||  isSignLocation_edit == 1){
                compHeight = '250px';
            }else {
                compHeight = '195px';
            }
        }

        const showSetReceiveRight = (isforwardrights == '1' || showReplyNotice == 1 ) && forwardflag == "1";
        return (
            <div>
                <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@ek7zn3`}
                    title={this.getTopTitle(requestname, forwardflag, ishideinput)}
                    visible={showForward}
                    parentClassName="wf-req-forward-dialog"
                    style={{ width: ishideinput ? 800 : 1100, padding: "10px 20px"  }}
                    maskClosable={false}
                    onCancel={this.cancelEvent}
                    buttons={
                        [
                            <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@2acct3@submit`} type="primary" size="large" disabled={loading} onClick={this.submitEvent}>{getLabel('725', "提交")}</Button>,
                            <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@qa2dp5@cancel`} type="ghost" size="large" disabled={loading} onClick={this.cancelEvent}>{getLabel('309', "关闭")}</Button>
                        ]
                    }
                    icon="icon-coms-workflow"
                    iconBgcolor='#0079DE'
                    loadCss={true}
                    initLoadCss={true}
                    //在公文使用该弹窗的时会出现弹窗遮盖的问题 加inOdoc控制渲染的dom--康乐
                    layout={typeof jQuery('.wf-req')[0] == 'undefined' && !inOdoc ? jQuery('#container')[0] : jQuery('.wf-req')[0]}
                >
                <div className="wea-req-forward-modal" style={{width:"100%",height:"100%"}}>
                    <WeaPopoverHrm ecId={`${this && this.props && this.props.ecId || ''}_WeaPopoverHrm@vyk6y2`} >
                    <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@tmzdra`} width={165} datas={this.getRightMenu()} onClick={this.onRightMenuClick}>
                        <div>
                            <RemindTypelist ecId={`${this && this.props && this.props.ecId || ''}_RemindTypelist@jvuep2`} {...remindInfo} callbackFun={(v)=>{
                                wfForwardStore.updateRemindType(v);
                            }} />
                        </div>
                        <Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@thwvft`} spinning={loading}>
                        <iframe className={loading?"wf-forward-iframe ":"wf-forward-iframe-hide"}></iframe>
                            <div className="wea-req-forward-content">
                                <div className="wea-req-forward-content-receive clearfix">
                                    <div className='label'>
                                        <span>*</span>
                                        <span>{receiveLabel}</span>
                                    </div>
                                    <div className='input'>
                                        {showForward && <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@85cfkn`} {...this.getUserBrowserProps()} onChange={this.doChangeEvent} dropAllUserGroup={dropAllUserGroup} />}
                                    </div>
                                    {forwardflag != "3" && (isopen != "1" || (isopen == "1" && choiceoperator == "1")) &&
                                        <div className='btns'>
                                            {
                                                isopen != "1" &&
                                                <Popover ecId={`${this && this.props && this.props.ecId || ''}_Popover@xsbidv`} placement="bottomLeft" title="" content={<OGroup ecId={`${this && this.props && this.props.ecId || ''}_OGroup@lh0fyh`} wfForwardStore={wfForwardStore} />}
                                                         trigger="click"
                                                         onVisibleChange={handleVisibleChange}
                                                         visible={isshowoperategroup}
                                                         overlayClassName="wea-req-forward-customer-me">
                                                    <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@uvi52z`} type="large" disabled={isdisabledbtns} title={getLabel('84511', "快捷选择人员")}><i className='icon-customer-me' /></Button>
                                                </Popover>
                                            }
                                            {
                                                (isopen != "1" || (isopen == "1" && choiceoperator == "1")) &&
                                                <Popover ecId={`${this && this.props && this.props.ecId || ''}_Popover@j5rjwe`} placement="bottomLeft" title="" content={<NodeOperator ecId={`${this && this.props && this.props.ecId || ''}_NodeOperator@o01nlr`} wfForwardStore={wfForwardStore} nodeOperatorTitle={nodeOperatorTitle}/>}
                                                         trigger="click"
                                                         onVisibleChange={handleShowNodeOperator}
                                                         visible={isshownodeoperators}
                                                         overlayClassName="wea-req-forward-node-operator">
                                                    <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@8cf46d`} type="large" style={{ 'margin-left': '5px' }} disabled={isdisabledbtns} title={nodeOperatorTitle.length > 0?nodeOperatorTitle:getLabel('84509', "选择节点参与人作为转发对象")}>
                                                        <img src="/images/forward_btn_operator.png" />
                                                    </Button>
                                                </Popover>
                                            }
                                        </div>
                                    }
                                </div>
                                {forwardflag == 2 && !isMulitTak &&
                                    <div className="wea-req-forward-content-takovertime">
                                        <span>{overTimeTakInfo && overTimeTakInfo[1]}</span>
                                        <WeaCheckbox ecId={`${this && this.props && this.props.ecId || ''}_WeaCheckbox@yq390o`}
                                        value={isOpenTakOvertime}
                                        display="switch"
                                        style={{display: 'inline'}}
                                        onChange={this.updateFormParams.bind(this, 'isOpenTakOvertime')}
                                        />
                                        {isOpenTakOvertime == 1 &&
                                        <div className="timeset">
                                            <WeaInputNumber ecId={`${this && this.props && this.props.ecId || ''}_WeaInputNumber@f9qbso`} defaultValue={0} min={0} max={23} onChange={this.updateFormParams.bind(this, 'takOverHours')}/>
                                        <span className="text">{getLabel('391', '小时')}</span>
                                            <WeaInputNumber ecId={`${this && this.props && this.props.ecId || ''}_WeaInputNumber@d3a2b4`} defaultValue={30} min={0} max={59} onChange={this.updateFormParams.bind(this, 'takOverMins')}/>
                                        <span className="text">{overTimeTakInfo && overTimeTakInfo[2]}</span>
                                            </div>
                                        }
                                    </div>
                                }
                                {showSetReceiveRight &&
                                    <div className="wea-req-forward-content-right">
                                        <div>
                                            <span className="label">{getLabel('81768', "接收人权限")}</span>
                                            {isforwardrights == '1' && <Checkbox ecId={`${this && this.props && this.props.ecId || ''}_Checkbox@agmplq`} checked={IsSubmitedOpinion == '1'} onChange={this.updateFormParams.bind(this, 'IsSubmitedOpinion')}>{IsSubmitedOpinionShowname}</Checkbox>}
                                            {isforwardrights == '1' && <Checkbox ecId={`${this && this.props && this.props.ecId || ''}_Checkbox@3gm0s1`} checked={IsBeForwardTodo == '1'} onChange={this.updateFormParams.bind(this, 'IsBeForwardTodo')}>{IsBeForwardTodoShowname}</Checkbox>}
                                            {showReplyNotice == 1 && <Checkbox ecId={`${this && this.props && this.props.ecId || ''}_Checkbox@opx3zu`} checked={isShowReplyNotice == '1'} onChange={this.updateFormParams.bind(this, 'isShowReplyNotice')}>{noticeLabel}</Checkbox>}
                                        </div>
                                    </div>
                                }
                                {
                                    forwardflag == "4" &&
                                    <div className="wea-req-forward-content-right">
                                        <div>
                                            <span className="label">{getLabel(391412, "接收人设置")}</span>
                                            <Checkbox ecId={`${this && this.props && this.props.ecId || ''}_Checkbox@o4kybb`} checked={isSubmitSign == '1'} onChange={this.updateFormParams.bind(this, 'isSubmitSign')}>{submitSignName}</Checkbox>
                                            <Checkbox ecId={`${this && this.props && this.props.ecId || ''}_Checkbox@rlpsd0`} checked={isChuanyue == '1'} onChange={this.updateFormParams.bind(this, 'isChuanyue')}>{chuanyueName}</Checkbox>
                                            <Checkbox ecId={`${this && this.props && this.props.ecId || ''}_Checkbox@ryttqr`} checked={isRemind == '1'} onChange={this.updateFormParams.bind(this, 'isRemind')}>{remindName}</Checkbox>
                                        </div>
                                    </div>
                                }
                                <div className="wea-req-forward-content-remark" style={{ 'display': ishideinput ? 'none' : 'block' }}>
                                    <div className='label wrap-remark-list' style={{ background: !isHasRemark ? "#ffffff" : "#F9F8F7", cursor: "default", paddingBottom: !isHasRemark ? "0" : "10px" }}>
                                        <i className="icon-coms-Need-feedback" style={{ marginRight: "10px", fontSize: "15px", color: "#AFAFAF ", lineHeight: "40px", display: "inline-block", verticalAlign: "bottom" }} />
                                        <span style={{ 'margin-left': (signinput.isSignMustInput == '1') ? '0px' : '5px', color: "#A0A0A0" }}>{getLabel('17614', "签字意见")}</span>
                                        {remarkMustInput && <span style={{ color: "red", marginLeft: "10px", verticalAlign: "bottom" }}>({getLabel(18019, "必填")})</span>}
                                        <span style={{ 'margin-left': '25px', 'font-weight': 'normal', color: "#A0A0A0" }}>
                                            {signinput.tempbeagenter != signinput.fileuserid ? agent : ''}
                                        </span>
                                        {this.getRemarkDom()}

                                    </div>

                                    <div className='remark' id="forwardremark_div" style={{ height: compHeight }}>
                                        {loaded && !ishideinput &&
                                            <SignInputck ecId={`${this && this.props && this.props.ecId || ''}_SignInputck@abvafa`}
                                                markInfo={signinput}
                                                isShowSignInput={true}
                                                editorId={'forwardremark'}
                                                maxHeight={150}
                                                visible={showForward}
                                                ref={"formwardRemarkCK"}
                                                isClear={isClear}
                                                requestid={requestid}
                                                initRemarkContent={initRemarkContent}
                                                remark={remark}
                                                workflowRequestLogId={workflowRequestLogId}
                                                globalStore={this.props.globalStore}
                                                layout={window}
                                                saveCallBack={() => {
                                                    wfForwardStore.initData();
                                                    this.props.globalStore.loadMarkInfo();
                                                }}
                                            />
                                        }
                                    </div>
                                </div>
                                {ishideinput && <div style={{ 'width': '100%', 'height': '60px' }}></div>}
                            </div>
                        </Spin>
                    </WeaRightMenu>
                    </WeaPopoverHrm>
                 
                 </div>
                </WeaDialog>
            </div>
        )
    }

    hasBottomConfig = () => {
        let { wfForwardStore,} = this.props;
        const { signinput = {} } = wfForwardStore;
        const { use_textarea_signinput, isannexupload_edit, isSignDoc_edit, isSignWorkflow_edit,remarkInfo={} ,isFormSignature, isSignLocation_edit } = signinput;
        const { handWrittenSignSwitch } = remarkInfo;
        let flag = false;
        if (isannexupload_edit == true|| isSignDoc_edit == true || isSignWorkflow_edit == true || isSignLocation_edit == true || handWrittenSignSwitch == 1){
            flag=true;
        }
        return flag;
    }
    getUserBrowserProps() {
        const { wfForwardStore, globalStore = {} } = this.props;
        const { selectOperatorsMax, operatorDatas, formParams = {}, hrmSqlWhere ,signinput = {}} = wfForwardStore;
        const { secLevelInfo = {},commonParam={} } = globalStore;
        const { field5, forwardflag = '1',f_weaver_belongto_userid='',f_weaver_belongto_usertype=''} = formParams;
        let {workflowid='',nodeid='',beagenter=''} = commonParam;
        let agentorbyagentid = beagenter;
        if(workflowid == ""){ //来自待办、已办列表
            workflowid= formParams["workflowid"];
            nodeid= formParams["nodeid"];
            agentorbyagentid = formParams["agentorbyagentid"];
        }
        let {hrmBrowser = {}} = signinput;
        hrmBrowser = toJS(hrmBrowser);
        const urserBrowserProps = {
            ...hrmBrowser,
            linkUrl: "/hrm/resource/HrmResource.jsp?id=",
            isAutoComplete: 1,
            isMultCheckbox: false,
            isDetail: false,
            viewAttr: 2,
            value: field5,
            zIndex: 1050,
            isShowGroup: true,
            forwardflag:forwardflag
        };

        urserBrowserProps.type = 17;
        urserBrowserProps.isSingle = false;
        urserBrowserProps.maxLength = selectOperatorsMax;
        urserBrowserProps.title = getLabel('83496', "多人力资源");
        urserBrowserProps.appendDatas = mobx.toJS(operatorDatas);
        delete urserBrowserProps['replaceDatas'];

        //浏览按钮设置密级参数
        let dataParams = {};
        if(secLevelInfo.hrmSqlWhere) {
            dataParams = {sqlwhere : secLevelInfo.hrmSqlWhere,bdf_wfid:workflowid,workflowid:workflowid,nodeid:nodeid,forwardflag:forwardflag};
        } else if(hrmSqlWhere) {
            dataParams = {sqlwhere : hrmSqlWhere,bdf_wfid:workflowid,workflowid:workflowid,nodeid:nodeid,forwardflag:forwardflag};
        }else{
            dataParams = {bdf_wfid:workflowid,workflowid:workflowid,nodeid:nodeid,forwardflag:forwardflag};
        }

        dataParams = {...dataParams,agentorbyagentid,f_weaver_belongto_userid,f_weaver_belongto_usertype};
        urserBrowserProps.dataParams = {...dataParams,...hrmBrowser.dataParams};
        urserBrowserProps.completeParams =  {...dataParams,...hrmBrowser.completeParams};
        urserBrowserProps.conditionDataParams =  {...dataParams,...hrmBrowser.conditionDataParams};

        //let urlparam = "?bdf_wfid="+workflowid+"&workflowid="+workflowid+"&nodeid="+nodeid+"&forwardflag="+forwardflag;
        //urserBrowserProps.dataURL = "/api/workflow/browser/data/"+urserBrowserProps.type+urlparam;
        //urserBrowserProps.conditionURL = "/api/workflow/browser/condition/"+urserBrowserProps.type+urlparam;
        //urserBrowserProps.completeURL = "/api/workflow/browser/complete/"+urserBrowserProps.type+urlparam;
        return urserBrowserProps;
    }

    updateFormParams(paramKey, o) {
        const { wfForwardStore } = this.props;
        const { setFormParams } = wfForwardStore;
        const updateParams = {};
        if (paramKey === 'IsSubmitedOpinion' || paramKey === 'IsBeForwardTodo'
            || paramKey === 'isSubmitSign' || paramKey === 'isChuanyue'
            || paramKey === 'isShowReplyNotice' || paramKey === 'isRemind')
        {
            updateParams[paramKey] = o.target.checked ? 1 : 0;
            // if(paramKey === 'IsSubmitedOpinion'){
            //     //关闭转发可提交意见时，也关闭转发接收人批注时提醒我
            //     updateParams['isShowReplyNotice'] = o.target.checked ? 1 : 0;
            // }
        } else {
            updateParams[paramKey] = o;
        }
        setFormParams(updateParams);
    }

    onCKEditorChange(datas) {
        //this.setState(datas);
    }

    onRightMenuClick = (key) =>  {
        this.submitEvent();
    }

    getRightMenu() {
        const { wfForwardStore } = this.props;
        const { loading } = wfForwardStore;
        let btnArr = [];
        btnArr.push({
            icon: <i className={`icon-workflow-Right-menu-Need-feedback`} />,
            content: getLabel('725', "提交"),
            disabled: loading
        });
        return btnArr;
    }

    doChangeEvent = (ids, names, datas) =>  {
        const { wfForwardStore } = this.props;
        const { setFormParams, setOperatorDatas, formParams } = wfForwardStore;
        const { field5, forwardflag = '1' } = formParams;
        setFormParams({ field5: ids });
        setOperatorDatas([]);
    }

    getTopTitle(titlename, forwardflag, ishideinput) {
        const { wfForwardStore } = this.props;
        const { formParams = {}, signinput = {}} = wfForwardStore;
        const { feedbacksign = '' } = formParams;

        //自定义按钮信息
        const {customBtnInfo = {}} = signinput;
        const {titlenameprefixInfo = {} ,} = customBtnInfo;
        let titlenameprefixSpan = titlenameprefixInfo[forwardflag] || '';

        let titlenameprefix = `${getLabel('24964', "流程转发")}：`
        if (forwardflag == '2') {
            titlenameprefix = `${getLabel('82578', "意见征询")}：`;
        }
        if (forwardflag == '3') {
            titlenameprefix = `${getLabel('23746', "流程转办")}：`;
        }
        if (forwardflag == '4') {
            titlenameprefix = `${getLabel(382671, "流程传阅")}：`;
        }
        if (forwardflag == '5') {
            titlenameprefix = `${getLabel(507272, "征询转办")}：`;
        }
        if(titlenameprefixSpan.length > 0){
            titlenameprefix = titlenameprefixSpan;
        }
        if (feedbacksign == '4') {
            titlenameprefix = `${getLabel('33956', "意见反馈")}：`;
        }

        return (
            <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@y8x4a3`}>
                <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@16m77u`} span="22" style={{ lineHeight: "45px", width: ishideinput ? '700px' : '1000px' }}>
                    {/* <div className="wea-workflow-icon">
                        <i className='icon-portal-workflow' />
                    </div> */}
                    <div className="wf-forward-title" style={{ width: ishideinput ? '635px' : '935px' }} title={titlename} dangerouslySetInnerHTML={{ __html: titlenameprefix + titlename }}></div>
                </Col>
            </Row>
        )
    }

    verifyRemarkMustInput(signinput = {},forwardflag = '1'){
        const {signMustInputTypes = [],isSignMustInput = '', isFormSignature = ""} = signinput;
        if(isSignMustInput == '1') {
            return true;
        } else if(isSignMustInput == '2') {
            return signMustInputTypes.indexOf(`forwardflag${forwardflag}`) > -1;
        } else {
            return false;
        }
    }

    //提交
    submitEvent = () =>  {
        const { wfForwardStore } = this.props;
        const { globalStore } = this.props;
        let openByDefaultBrowser = '';
        if(globalStore){
            const { submitParam } = globalStore;
            openByDefaultBrowser = submitParam.openByDefaultBrowser;
        }
        const { operatorDatas, signinput = {}, formParams = {}, requestType, currentnodetype, doSubmitPost } = wfForwardStore;
        const { field5, IsSubmitedOpinion, IsBeForwardTodo, forwardflag = '1' } = formParams;
        const {signMustInputTypes = [],isSignMustInput = '', isFormSignature = "", customBtnInfo = {}} = signinput;
        const { overTimeTakInfo = {}, btnNameInfo = {} } = customBtnInfo;
        let forwardremarkInfo = this.getSignInputInfo();
        //验证签字意见必填
        let flag = true;
        if (this.verifyRemarkMustInput(signinput,forwardflag) && isFormSignature!='1') {
            let forwardremarkcontent = window.CK_REF.forwardremark.getEditor().getData();
            flag = SignUtil.chekcremark(forwardremarkcontent, forwardremarkInfo);
        }else if(forwardremarkInfo==false && isFormSignature=='1') {
            //签章必填已经在getSignInputInfo中提示了，直接return即可
           return;
        }
        if ((!flag && isFormSignature!='1') || field5 == '') {
            message.warning(getLabel(384146, '必要信息不完整，红色*号为必填项！'), 2);
            return;
        }
        if(formParams.isOpenTakOvertime == 1 && !formParams.takOverHours && !formParams.takOverMins) {
            message.warning(overTimeTakInfo && overTimeTakInfo[3], 2);
            return;
        }

        const forwardPara = {};
        forwardPara.openByDefaultBrowser = openByDefaultBrowser;
        if (currentnodetype == "3") { //办结
            forwardPara.IsBeForwardSubmitNotaries = IsSubmitedOpinion;
            forwardPara.IsBeForward = IsBeForwardTodo;
        } else {
            if (requestType == "1") { //待办
                forwardPara.IsSubmitedOpinion = IsSubmitedOpinion;
                forwardPara.IsBeForwardTodo = IsBeForwardTodo;
            } else { //已办
                forwardPara.IsBeForwardSubmitAlready = IsSubmitedOpinion;
                forwardPara.IsBeForwardAlready = IsBeForwardTodo;
            }
        }
        //在这里把签字意见引用加上，字段为remark
        let params = objectAssign({}, { 
            operate: 'save',
            field5: field5
        }, forwardPara, formParams,forwardremarkInfo);
        const _this = this;
        if (signinput.needconfirm === "1" && (forwardflag == "2" || forwardflag == "3")) {
            confirm({
                zIndex: 1050,
                content: getLabel('519085', "确认是否{1}？").replace("{1}", forwardflag == "2" ? btnNameInfo[2] : btnNameInfo[3]),
                onOk() {
                    doSubmitPost(params);
                },
                onCancel() { }
            });
        } else {
            doSubmitPost(params);
        }
    }

    contentUtil = (str) => {
      let head = str.substr(0, str.indexOf("<div _quotoContent='true'"));
      str = str.slice(str.indexOf("<div _quotoContent='true'"));
      let pic = `[${getLabel(528760 , '图片')}]`;
      str = str.replace(/<img.*?>/g, pic)
      str = str.replace(/<[^>]*>|<\/[^>]*>/gm, "")
      str = str.replace(/\r|\n|\\s/gm, "");
      str = '<div class="remark-quote">' + str + '</div>'
      str = head + str  + "</div>";
      return str;
  }

    // 点击删除一个签字意见
    deleteItem(key, event) {
        const { wfForwardStore } = this.props;
        const { remarkMap } = wfForwardStore;
        remarkMap.delete(key);
    }
    //渲染引用签字意见列表
    getRemarkDom =
        () => {
            const { wfForwardStore } = this.props;
            const { remarkMap } = wfForwardStore;
            let arr = [];
            remarkMap.forEach((value, key, map) => {
                const item = <div className='remark_list_dom' style={{ position: "relative" }}>
                    <div dangerouslySetInnerHTML={{ __html: this.contentUtil(value) }}></div>
                    <Icon ecId={`${this && this.props && this.props.ecId || ''}_Icon@tb2va6@${key}`} type="cross" className="wf-req-sign-input-delete" onClick={this.deleteItem.bind(this, key)} />
                </div>
                if (value !== '') {
                    arr.push(item)
                }
            })
            return arr;
        }

    getSignInputInfo() {
        const { wfForwardStore } = this.props;
        const { formParams = {}, signinput = {}, remarkMap} = wfForwardStore;
        const { isHideInput = '' ,extendParams = {},use_textarea_signinput = 0, isFormSignature = '',isSignMustInput=''} = signinput;
        if (isHideInput == '1') return {};
        const ckState = this.refs.formwardRemarkCK.state;
        const { requestid = -1,forwardflag = '1' } = formParams;
        const { signworkflowids = '', signdocids = '', remarkLocation = '', annexdocinfos = [], signdocreplacedata = [], signworkflowreplacedata = [], signhandwrittenid} = ckState;
        const annexdocids = [];
        annexdocinfos.map(o => annexdocids.push(o.fileid));
        let params = {
            signworkflowids: signworkflowids,
            signdocids: signdocids,
            remarkLocation: remarkLocation,
            'field-annexupload': annexdocids.join(','),
            'field-annexupload-request': requestid,
            handWrittenSign:signhandwrittenid,
        }
        if(isFormSignature == '1'){
            const isSignatureMustInput = this.verifyRemarkMustInput(signinput,forwardflag);
            if(window.saveAutographMul && window.saveAutographMul.wfWeaAutographCompforwardremark){
                let requestlog = window.saveAutographMul.wfWeaAutographCompforwardremark(isSignatureMustInput)
                if(requestlog === true || requestlog == -1){

                }else if(!isNaN(requestlog) && parseInt(requestlog) > 0){
                    params.workflowRequestLogId=requestlog;
                }else{
                    if(requestlog == "-2")
                        message.warning(getLabel(386186,'"签字意见"未填写'), 2);
                    else
                        message.warning(getLabel(528568,"签章保存失败"), 2);
                    return false;
                }
            }
        }else{
            const remark = window.CK_REF.forwardremark.getEditor().getData();
            let _remark = remark.replace(/​/ig, ''); //&#8203\
    
            const {wfSignDefaultFontFamily = '',wfSignDefaultFontSize = ''} = extendParams;
            _remark = SignUtil.appendDefaultSytle(_remark,wfSignDefaultFontFamily,wfSignDefaultFontSize,use_textarea_signinput);
            let tt = '';
            remarkMap.forEach((value, key, map) => {
                tt += value;
            })
            _remark = tt + _remark;
            params.remark = _remark;
        }
        return params;
    }

    cancelEvent = () =>  {
        const { wfForwardStore } = this.props;
        const {setFormParams,closeForwarDialog,callBackActions = {},signinput, setSignInput} = wfForwardStore;
        const {isFormSignature="",isSignMustInput=""}=signinput;
        if(window.CK_REF && window.CK_REF.forwardremark && window.CK_REF.forwardremark.getEditor()) {
            const remark = window.CK_REF.forwardremark.getEditor().getData();
            let _remark = remark.replace(/​/ig, ''); //&#8203\
            setFormParams({remark:_remark});
        }
        if(signinput.isFormSignature==1){
                const requestlog = window.saveAutograph(false,true);
                if(requestlog.indexOfAutograph == 'wfWeaAutographCompforwardremark'){
                    setFormParams({workflowRequestLogId:requestlog.recordId });
                }
            }
        wfForwardStore.setShowForward({ showForward: false, requestid: -1,isClickCloseBtn:true });
        //关闭窗口，将ReqIndex.js中的参数也修改，避免出现问题
        if (closeForwarDialog && typeof closeForwarDialog == "function") {
            closeForwarDialog();
        }
        const {callBackfun} = callBackActions;
        typeof callBackfun === 'function' && callBackfun();
    }
}